﻿using CommandLine;
using NK.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

class Program
{
    static void Main(string[] args)
    {
        var verbs = LoadVerbs();

        Parser.Default.ParseArguments(args, verbs)
              .WithParsed(Run)
              .WithNotParsed(HandleErrors);
    }

    private static Type[] LoadVerbs()
    {
        return Assembly.GetExecutingAssembly().GetTypes()
            .Where(t => t.BaseType == typeof(OptionHandlerBase)).ToArray();
    }

    private static void Run(object obj)
    {
        var handle = obj as OptionHandlerBase;
        handle.HandleOption();
    }

    private static void HandleErrors(IEnumerable<Error> obj)
    {
    }
}